//***************************************************************************
//*
//*	File:			dswl_application.cpp
//*	Description:	Wrapper for IApplication interface
//*
//***************************************************************************

//
//--------------------------------------------------------------- PRECOMPILED
//

#include	"stdafx.h"

//
//--------------------------------------------------- DECLARATION DEPENDENCIES
//

//
//--------------------------------------------------------------- DECLARATION
//

#include	"../Inc/dswl_application.h"

//
//--------------------------------------------------- DEFINITION DEPENDENCIES
//

//
//-------------------------------------------------------------- PREPROCESSOR
//

#ifdef		_DEBUG
#define		new DEBUG_NEW
#undef		THIS_FILE
static		char THIS_FILE[] = __FILE__;
#endif

//
//---------------------------------------------------------------- DEFINITION
//

/*
static void g_TestCasts()
{
	// test _safe_ conversions
	IApplication* pITest;
	CIApplication test	 ( pITest );
	CIApplication test2 = pITest ;

	test = test2;
	test = pITest;

	#ifdef _DSWL_SWITCH_USE_AUTOCAST

	// test _critical_ conversions
	pITest = test;
	CComPtr< IApplication > tmplTest = test;

	#endif
}
*/

//
//---------------------------------------------------------------------------------------------------
//*************************************     CON/DESTRUCTION     *************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					  Constructor
//***************************************************************************************************
//**	@DOC		CONSTRUCTION
//**	@MFUNC		Default constructor
//**	@PARM		[in] A pointer to the interface to attach to
//**	@END
//***************************************************************************************************
//inline
CIApplication::CIApplication( IApplication* a_pIApplication /*= NULL*/ )
{
	this->m_pIApplication = a_pIApplication;
}

//***************************************************************************************************
//**																					   Destructor
//***************************************************************************************************
//**	@DOC		CONSTRUCTION
//**	@MFUNC		Default destructor
//**	@END
//***************************************************************************************************
//inline
CIApplication::~CIApplication()
{
	this->m_pIApplication = NULL;	// explicitly release the interface now
}

//
//---------------------------------------------------------------------------------------------------
//***************************************     PROPERTIES     ****************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																						 IsActive
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Determines whether the application is active
//**	@RDESC		<t TRUE> if the application is active, <t FALSE> otherwise.
//**	@END
//***************************************************************************************************
//inline
BOOL CIApplication::IsActive( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return FALSE;
	}

	//
	//	DELEGATE
	//
	VARIANT_BOOL varResult( FALSE );

	DSWL_VERIFY( this->m_pIApplication->get_Active( &varResult ) );

	return varResult;
}

//***************************************************************************************************
//**																						IsVisible
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Determines whether the application is visible
//**	@RDESC		<t TRUE> if the application is visible, <t FALSE> otherwise.
//**	@END
//***************************************************************************************************
//inline
BOOL CIApplication::IsVisible( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return FALSE;
	}

	//
	//	DELEGATE
	//
	VARIANT_BOOL varResult( FALSE );

	DSWL_VERIFY( this->m_pIApplication->get_Visible( &varResult ) );

	return varResult;
}
 
//***************************************************************************************************
//**																				   GetWindowState		
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's window state
//**	@RDESC		The window state
//**	@END
//***************************************************************************************************
//inline
DsWindowState CIApplication::GetWindowState( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	DsWindowState enuResult;

	DSWL_VERIFY( this->m_pIApplication->get_WindowState( &enuResult ) );

	return enuResult;
}

//***************************************************************************************************
//**																					GetWindowRect 
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's window rect
//**	@RDESC		The window rect
//**	@END
//***************************************************************************************************
//inline
CRect CIApplication::GetWindowRect( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CRect rectWindow;

	DSWL_VERIFY( this->m_pIApplication->get_Top	( &rectWindow.top    ) );
	DSWL_VERIFY( this->m_pIApplication->get_Left	( &rectWindow.left   ) );
	DSWL_VERIFY( this->m_pIApplication->get_Width	( &rectWindow.right  ) );
	DSWL_VERIFY( this->m_pIApplication->get_Height( &rectWindow.bottom ) );

	rectWindow.right  += rectWindow.left;
	rectWindow.bottom += rectWindow.top ;

	return rectWindow;
}

//***************************************************************************************************
//**																					  GetFullName 		
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's full name
//**	@RDESC		The application's full name
//**	@END
//***************************************************************************************************
//inline
CString CIApplication::GetFullName( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CComBSTR bszFullName( _T("") );

	DSWL_VERIFY( this->m_pIApplication->get_FullName( &bszFullName ) );

	return bszFullName;
}

//***************************************************************************************************
//**																						  GetName
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's name
//**	@RDESC		The application's name
//**	@END
//***************************************************************************************************
//inline
CString CIApplication::GetName( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CComBSTR bszName( _T("") );

	DSWL_VERIFY( this->m_pIApplication->get_Name( &bszName ) );

	return bszName;
}

//***************************************************************************************************
//**																					   GetVersion
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's version
//**	@RDESC		The application's version
//**	@END
//***************************************************************************************************
//inline
CString CIApplication::GetVersion( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CComBSTR bszVersion( _T("") );

	DSWL_VERIFY( this->m_pIApplication->get_Version( &bszVersion ) );

	return bszVersion;
}

//***************************************************************************************************
//**																						  GetPath
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's path
//**	@RDESC		The application's path
//**	@END
//***************************************************************************************************
//inline
CString CIApplication::GetPath( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CComBSTR bszPath( _T("") );

	DSWL_VERIFY( this->m_pIApplication->get_Path( &bszPath ) );

	return bszPath;
}

//***************************************************************************************************
//**																			  GetCurrentDirectory
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's current directory
//**	@RDESC		The application's current directory
//**	@END
//***************************************************************************************************
//inline
CString CIApplication::GetCurrentDirectory( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CComBSTR bszCurrentDirectory( _T("") );

	DSWL_VERIFY( this->m_pIApplication->get_CurrentDirectory( &bszCurrentDirectory ) );

	return bszCurrentDirectory;
}

//***************************************************************************************************
//**																					   GetWindows
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's windows
//**	@RDESC		A pointer to the windows' interface
//**	@END
//***************************************************************************************************
//inline
CIWindows CIApplication::GetWindows( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_Windows( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IWindows, &IID_IWindows > pIWindows ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetWindows );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIWindows.p;												
}

//***************************************************************************************************
//**																					 GetDocuments
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's documents
//**	@RDESC		A pointer to the documents' interface
//**	@END
//***************************************************************************************************
//inline
CIDocuments CIApplication::GetDocuments( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_Documents( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IDocuments, &IID_IDocuments > pIDocuments ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetDocuments );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIDocuments.p;												
}

//***************************************************************************************************
//**																					  GetProjects
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's projects
//**	@RDESC		A pointer to the projects' interface
//**	@END
//***************************************************************************************************
//inline
CIProjects CIApplication::GetProjects( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_Projects( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IProjects, &IID_IProjects > pIProjects ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetProjects );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIProjects.p;												
}

//***************************************************************************************************
//**																					GetTextEditor
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's text editor
//**	@RDESC		A pointer to the text editor's interface
//**	@END
//***************************************************************************************************
//inline
CITextEditor CIApplication::GetTextEditor( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_TextEditor( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< ITextEditor, &IID_ITextEditor > pITextEditor ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetTextEditor );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pITextEditor.p;												
}

//***************************************************************************************************
//**																					  GetDebugger
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's debugger
//**	@RDESC		A pointer to the debugger's interface
//**	@END
//***************************************************************************************************
//inline
CIDebugger CIApplication::GetDebugger( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_Debugger( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IDebugger, &IID_IDebugger > pIDebugger ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetDebugger );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIDebugger.p;												
}

//***************************************************************************************************
//**																				  GetActiveWindow
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's active window
//**	@RDESC		A pointer to the active window's interface
//**	@END
//***************************************************************************************************
//inline
CIGenericWindow CIApplication::GetActiveWindow( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_ActiveWindow( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IGenericWindow, &IID_IGenericWindow > pIGenericWindow ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetActiveWindow );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIGenericWindow.p;												
}

//***************************************************************************************************
//**																				GetActiveDocument
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's active document
//**	@RDESC		A pointer to the active document's interface
//**	@END
//***************************************************************************************************
//inline
CIGenericDocument CIApplication::GetActiveDocument( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_ActiveDocument( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IGenericDocument, &IID_IGenericDocument > pIGenericDocument ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetActiveDocument );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIGenericDocument.p;												
}

//***************************************************************************************************
//**																				 GetActiveProject
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's active project
//**	@RDESC		A pointer to the active project's interface
//**	@END
//***************************************************************************************************
//inline
CIGenericProject CIApplication::GetActiveProject( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	/*DSWL_VERIFY(*/ this->m_pIApplication->get_ActiveProject( &pIDispatch ) /*)*/;

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IGenericProject, &IID_IGenericProject > pIGenericProject ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetActiveProject );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIGenericProject.p;												
}

//***************************************************************************************************
//**																		   GetActiveConfiguration
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the application's active configuration
//**	@RDESC		A pointer to the active configuration's interface
//**	@END
//***************************************************************************************************
//inline
CIConfiguration CIApplication::GetActiveConfiguration( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch* pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIApplication->get_ActiveConfiguration( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IConfiguration, &IID_IConfiguration > pIConfiguration ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIApplication::GetActiveConfiguration );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIConfiguration.p;												
}

//***************************************************************************************************
//**																						SetActive
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Activates or deactivates the application
//**	@PARM		[in] A flag indicating whether to activate or deactivate the application
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetActive( BOOL a_bActive ) 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	VARIANT_BOOL varActive( a_bActive );

	DSWL_VERIFY( this->m_pIApplication->put_Active( varActive ) );
}

//***************************************************************************************************
//**																					   SetVisible
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Shows or hides the application
//**	@PARM		[in] A flag indicating whether to show or hide the application
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetVisible( BOOL a_bVisible ) 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	VARIANT_BOOL varVisible( a_bVisible );

	DSWL_VERIFY( this->m_pIApplication->put_Visible( varVisible ) );
}

//***************************************************************************************************
//**																				   SetWindowState		
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Sets the application's window state
//**	@PARM		[in] The desired window state
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetWindowState( DsWindowState a_enuState ) 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	DSWL_VERIFY( this->m_pIApplication->put_WindowState( a_enuState ) );
}

//***************************************************************************************************
//**																					SetWindowRect	
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Sets the application's window rect
//**	@PARM		[in] The window rect
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetWindowRect( const CRect& a_rectWindow ) 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	DSWL_VERIFY( this->m_pIApplication->put_Top	( a_rectWindow.top		) );
	DSWL_VERIFY( this->m_pIApplication->put_Left	( a_rectWindow.left		) );
	DSWL_VERIFY( this->m_pIApplication->put_Width	( a_rectWindow.Width () ) );
	DSWL_VERIFY( this->m_pIApplication->put_Height( a_rectWindow.Height() ) );
}

//***************************************************************************************************
//**																			  SetCurrentDirectory		
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Sets the application's current directory
//**	@PARM		[in] The path
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetCurrentDirectory( const CString& a_strPath ) 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CComBSTR bszPath( a_strPath );

	DSWL_VERIFY( this->m_pIApplication->put_CurrentDirectory( bszPath	) );
}

//***************************************************************************************************
//**																				 SetActiveProject		
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Sets the application's active project
//**	@PARM		[in] A pointer to the project's interface
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetActiveProject( IGenericProject* a_pIProject ) 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	CHECK VALIDITY
	//
	if ( NULL == a_pIProject )
	{
		return;
	}

	//
	//	DELEGATE
	//
	DSWL_VERIFY( this->m_pIApplication->put_ActiveProject( a_pIProject ) );
}

//***************************************************************************************************
//**																		   SetActiveConfiguration		
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Sets the application's active configuration
//**	@PARM		[in] A pointer to the configuration's interface
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetActiveConfiguration( IConfiguration* a_pIConfig ) 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	CHECK VALIDITY
	//
	if ( NULL == a_pIConfig )
	{
		return;
	}

	//
	//	DELEGATE
	//
	DSWL_VERIFY( this->m_pIApplication->put_ActiveConfiguration( a_pIConfig ) );
}

//
//---------------------------------------------------------------------------------------------------
//***************************************     INFORMATION     ***************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																						   IsNull
//***************************************************************************************************
//**	@DOC		INFORMATION
//**	@MFUNC		Determines whether the internal pointer is <t NULL>
//**	@RDESC		<t TRUE> if the internal pointer is <t NULL>, <t FALSE> otherwise.
//**	@END
//***************************************************************************************************
//inline
BOOL CIApplication::IsNull( void ) const
{
	return ( NULL == this->m_pIApplication.p );
}

//***************************************************************************************************
//**																						  IsValid
//***************************************************************************************************
//**	@DOC		INFORMATION
//**	@MFUNC		Determines whether the internal pointer differs from <t NULL>
//**	@RDESC		<t TRUE> if the internal pointer differs from <t NULL>, <t FALSE> otherwise.
//**	@END
//***************************************************************************************************
//inline
BOOL CIApplication::IsValid( void ) const
{
	return ( NULL != this->m_pIApplication.p );
}

//
//---------------------------------------------------------------------------------------------------
//****************************************     EXECUTION     ****************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																				   EnableModeless	  
//***************************************************************************************************
//**	@DOC		EXECUTION
//**	@MFUNC		Enables or disables modeless mode
//**	@PARM		[in] A flag indicating wheter to enable or disable modeless mode
//**	@END
//***************************************************************************************************
//inline
void CIApplication::EnableModeless( BOOL a_bEnable ) 
{
	ASSERT( TRUE == this->IsValid() );

	DSWL_VERIFY( this->m_pIApplication->EnableModeless( a_bEnable ? VARIANT_TRUE : VARIANT_FALSE ) );
}

//***************************************************************************************************
//**																				   ExecuteCommand		  
//***************************************************************************************************
//**	@DOC		EXECUTION
//**	@MFUNC		Executes the specified command
//**	@PARM		[in] The command to execute
//**	@END
//***************************************************************************************************
//inline
void CIApplication::ExecuteCommand( const CString& a_strCommand ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR bszCommand( a_strCommand );

	DSWL_VERIFY( this->m_pIApplication->ExecuteCommand( bszCommand ) );
}

//***************************************************************************************************
//**																			  PrintToOutputWindow			  
//***************************************************************************************************
//**	@DOC		EXECUTION
//**	@MFUNC		Prints the specified message to the output window
//**	@PARM		[in] The message to output
//**	@END
//***************************************************************************************************
//inline
void CIApplication::PrintToOutputWindow( const CString& a_strMessage ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR bszMessage( a_strMessage );

	DSWL_VERIFY( this->m_pIApplication->PrintToOutputWindow( bszMessage ) );
}

//***************************************************************************************************
//**																							 Quit
//***************************************************************************************************
//**	@DOC		EXECUTION
//**	@MFUNC		Quits the application
//**	@END
//***************************************************************************************************
//inline
void CIApplication::Quit( void ) 
{
	ASSERT( TRUE == this->IsValid() );

	DSWL_VERIFY( this->m_pIApplication->Quit() );
}

//
//---------------------------------------------------------------------------------------------------
//******************************************     BUILD     ******************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																							Clean  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Cleans the specified configuration and all of its dependencies
//**	@PARM		[in] A pointer to the configuration's interface
//**	@END
//***************************************************************************************************
//inline
void CIApplication::Clean( IConfiguration* a_pIConfig ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComVariant varConfig( a_pIConfig );

	DSWL_VERIFY( this->m_pIApplication->Clean( varConfig ) );
}

//***************************************************************************************************
//**																							Build	  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Builds the specified configuration and all of its dependencies
//**	@PARM		[in] A pointer to the configuration's interface
//**	@END
//***************************************************************************************************
//inline
void CIApplication::Build( IConfiguration* a_pIConfig ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComVariant varConfig( a_pIConfig );

	DSWL_VERIFY( this->m_pIApplication->Build( varConfig ) );
}

//***************************************************************************************************
//**																					   RebuildAll		  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Rebuilds the specified configuration and all of its dependencies
//**	@PARM		[in] A pointer to the configuration's interface
//**	@END
//***************************************************************************************************
//inline
void CIApplication::RebuildAll( IConfiguration* a_pIConfig ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComVariant varConfig( a_pIConfig );

	DSWL_VERIFY( this->m_pIApplication->RebuildAll( varConfig ) );
}

//***************************************************************************************************
//**																						  Execute  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Executes the specified configuration
//**	@PARM		[in] A pointer to the configuration's interface
//**	@END
//***************************************************************************************************
//inline
void CIApplication::Execute( IConfiguration* a_pIConfig ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComVariant varConfig( a_pIConfig );

	DSWL_VERIFY( this->m_pIApplication->ExecuteConfiguration( varConfig ) );
}
 
//***************************************************************************************************
//**																						GetErrors	  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Determines the number of errors that occured during the last build
//**	@RDESC		The number of errors
//**	@END
//***************************************************************************************************
//inline
long CIApplication::GetErrors( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	long lErrors = 0;

	DSWL_VERIFY( this->m_pIApplication->get_Errors( &lErrors ) );

	return lErrors;
}

//***************************************************************************************************
//**																					  GetWarnings  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Determines the number of errors that occured during the last build
//**	@RDESC		The number of warnings
//**	@END
//***************************************************************************************************
//inline
long CIApplication::GetWarnings( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	long lWarnings = 0;

	DSWL_VERIFY( this->m_pIApplication->get_Warnings( &lWarnings ) );

	return lWarnings;
}
 
//
//---------------------------------------------------------------------------------------------------
//***********************************     PROJECT MANAGEMENT     ************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					   AddProject	  
//***************************************************************************************************
//**	@DOC		PROJECT MANAGEMENT
//**	@MFUNC		Adds the specified project ot the current workspace
//**	@PARM		[in] The project's name
//**	@PARM		[in] The porject's path
//**	@PARM		[in] The project's type
//**	@PARM		[in] A flag indicating whether to add default folders to the project
//**	@END
//***************************************************************************************************
//inline
void CIApplication::AddProject( const CString& a_strName, const CString& a_strPath, const CString& a_strType, BOOL a_bAddDefaultFolders ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR bszName( a_strName );
	CComBSTR bszPath( a_strPath );
	CComBSTR bszType( a_strType );

	DSWL_VERIFY( this->m_pIApplication->AddProject( bszName, bszPath, bszType, a_bAddDefaultFolders ? VARIANT_TRUE : VARIANT_FALSE ) );
}

//
//---------------------------------------------------------------------------------------------------
//************************************     ADDIN MANAGEMENT     *************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					   AddCommand	  
//***************************************************************************************************
//**	@DOC		ADDIN MANAGEMENT
//**	@MFUNC		Adds the specified command
//**	@PARM		[in] The command's name
//**	@PARM		[in] The command's method
//**	@PARM		[in] The command's offset in the bitmap resource list
//**	@PARM		[in] The AddIn's cookie
//**	@END
//***************************************************************************************************
//inline
BOOL CIApplication::AddCommand( const CString& a_strName, const CString& a_strMethodName, long a_lBitmapOffset, DWORD a_dwCookie ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR		bszName		( a_strName			);
	CComBSTR		bszMethod	( a_strMethodName	);
	VARIANT_BOOL	varResult	( FALSE				);

	DSWL_VERIFY( this->m_pIApplication->AddCommand( bszName, bszMethod, a_lBitmapOffset, a_dwCookie, &varResult ) );

	return varResult;
}

//***************************************************************************************************
//**																			  AddCommandBarButton		  
//***************************************************************************************************
//**	@DOC		ADDIN MANAGEMENT
//**	@MFUNC		Adds the specified button to the command bar
//**	@PARM		[in] The button type
//**	@PARM		[in] The command name
//**	@PARM		[in] The AdddIn's cookie
//**	@END
//***************************************************************************************************
//inline
void CIApplication::AddCommandBarButton( long a_lButtonType, const CString& a_strName, DWORD a_dwCookie ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR bszName( a_strName	);

	DSWL_VERIFY( this->m_pIApplication->AddCommandBarButton( a_lButtonType, bszName, a_dwCookie ) );
}

//***************************************************************************************************
//**																					AddKeyBinding  
//***************************************************************************************************
//**	@DOC		ADDIN MANAGEMENT
//**	@MFUNC		Adds the specified key binding
//**	@PARM		[in] The key to bind
//**	@PARM		[in] The command to bind the key to
//**	@PARM		[in] The editor to set the binding for
//**	@END
//***************************************************************************************************
//inline
void CIApplication::AddKeyBinding( const CString& a_strKey, const CString& a_strCommand, const CString& a_strEditor ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR bszKey		( a_strKey		);
	CComBSTR bszCommand	( a_strCommand	);
	CComBSTR bszEditor	( a_strEditor	);

	DSWL_VERIFY( this->m_pIApplication->AddKeyBinding( bszKey, bszCommand, bszEditor ) );
}

//***************************************************************************************************
//**																					 SetAddInInfo	  
//***************************************************************************************************
//**	@DOC		ADDIN MANAGEMENT
//**	@MFUNC		Registers the specified AddIn
//**	@PARM		[in] The application's instance handle
//**	@PARM		[in] The Command interface's dispatch interface
//**	@PARM		[in] The resource ID for medium size button bitmaps
//**	@PARM		[in] The resource ID for large  size button bitmaps
//**	@END
//***************************************************************************************************
//inline
void CIApplication::SetAddInInfo( HINSTANCE a_hInstance, IDispatch* a_pIDispatchCmd, long a_lIDBitmapResMedium, long a_lIDBitmapResLarge, DWORD a_dwCookie ) 
{
	ASSERT( TRUE == this->IsValid() );

	DSWL_VERIFY( this->m_pIApplication->SetAddInInfo( reinterpret_cast< long > (a_hInstance), a_pIDispatchCmd, a_lIDBitmapResMedium, a_lIDBitmapResLarge, a_dwCookie ) );
}

//***************************************************************************************************
//**																			  GetPackageExtension		  
//***************************************************************************************************
//**	@DOC		ADDIN MANAGEMENT
//**	@MFUNC		Determines the dispatch interface for the specified extension package
//**	@PARM		[in] The extension's name
//**	@RDESC		A pointer to the extension object's dispatch interface
//**	@END
//***************************************************************************************************
//inline
IDispatch* CIApplication::GetPackageExtension( const CString& a_strExtensionName ) 
{
	ASSERT( TRUE == this->IsValid() );

	IDispatch*	pIDispatch	= NULL;
	CComBSTR	bszName		( a_strExtensionName );

	DSWL_VERIFY( this->m_pIApplication->GetPackageExtension( bszName, &pIDispatch ) );

	return pIDispatch;
}

//
//---------------------------------------------------------------------------------------------------
//****************************************     OPERATORS     ****************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					  operator ==
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The text document to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIApplication::operator == ( const CIApplication& a_Other ) const 
{
	return this->m_pIApplication == a_Other.m_pIApplication;
}

//***************************************************************************************************
//**																					  operator !=
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The text document to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIApplication::operator != ( const CIApplication& a_Other ) const 
{
	return this->m_pIApplication != a_Other.m_pIApplication;
}

//***************************************************************************************************
//**																					  operator <=
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The text document to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIApplication::operator <= ( const CIApplication& a_Other ) const 
{
	return this->m_pIApplication.p <= a_Other.m_pIApplication.p;
}

//***************************************************************************************************
//**																					  operator >=
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The text document to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIApplication::operator >= ( const CIApplication& a_Other ) const 
{
	return this->m_pIApplication.p >= a_Other.m_pIApplication.p;
}

//***************************************************************************************************
//**																					   operator <
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The text document to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIApplication::operator < ( const CIApplication& a_Other ) const 
{
	return this->m_pIApplication.p < a_Other.m_pIApplication.p;
}

//***************************************************************************************************
//**																					   operator >
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The text document to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIApplication::operator > ( const CIApplication& a_Other ) const 
{
	return this->m_pIApplication.p > a_Other.m_pIApplication.p;
}

//***************************************************************************************************
//**																					   operator =
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Copy operator
//**	@PARM		[in] The text document to attach to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIApplication& CIApplication::operator = ( IApplication* a_pIOther ) 
{
	this->m_pIApplication = a_pIOther;

	return (*this);
}

//***************************************************************************************************
//**																					   operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Dereference operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
IApplication* CIApplication::operator * ( void ) 
{
	return this->m_pIApplication.p;
}

//***************************************************************************************************
//**																				 const operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Dereference operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
const IApplication* CIApplication::operator * ( void ) const 
{
	return this->m_pIApplication.p;
}

//***************************************************************************************************
//**																					  operator ->
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Member access operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
IApplication* CIApplication::operator -> ( void ) 
{
	return * (*this);
}

//***************************************************************************************************
//**																				const operator ->
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Member access operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
const IApplication* CIApplication::operator -> ( void ) const 
{
	return * (*this);
}

//---------------------------------------------------------------------------------------------------
//***************************************************************************************************
//---------------------------------------------------------------------------------------------------

#ifdef _DSWL_SWITCH_USE_AUTOCAST
#ifdef _DSWL_SWITCH_USE_UNSAFE_AUTOCAST

//***************************************************************************************************
//**																				 const operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		TypeCast operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIApplication::operator IApplication* ( void ) const 
{
	return this->m_pIApplication.p;
}

#else

//***************************************************************************************************
//**																					   operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		TypeCast operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIApplication::operator IApplication* ( void ) 
{
	return this->m_pIApplication.p;
}

//***************************************************************************************************
//**																				 const operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		TypeCast operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIApplication::operator const IApplication* ( void ) const 
{
	return this->m_pIApplication.p;
}

#endif
#endif


